package is.model;

import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author aspr0
 */
public class DataSource
{
    private static Connection connection;

    public static void establishConnection() throws SQLException, NamingException
    {
        InitialContext ic = new InitialContext();
        javax.sql.DataSource ds = (javax.sql.DataSource) ic.lookup("jdbc/mysql.iswd-boris");

        connection = ds.getConnection();
    }

    public static void closeConnection() throws SQLException
    {
        connection.close();
    }

    public static Connection getConnection()
    {
        return connection;
    }
}
